import { createRouter, createWebHistory } from "vue-router";
import Layout from "@/layout/LayOut.vue";
// import MainContent from "../views/MainContent.vue";

const router = createRouter({
    history: createWebHistory(),
    routes: [
        {
            path: "/login",
            name: "login",
            component: () => import("@/views/login/LoginIndex.vue"),
            hidden: true
        },
        {
            path: "/screen",
            name: "screen",
            component: () => import("@/views/screen/DataView.vue"),
            hidden: true  // 登录后才能访问
        },
        // {
        //         path: '/404',
        //         component: () => import('@/views/404'),
        //         hidden: true
        // },
        {
            path: "/",
            name:'layout',
            redirect: "/login",
            component: Layout,
            meta: { title: "首页" },
            children: [
                {
                    path: "/home",
                    name: "home",
                    component: () => import("@/views/HomeIndex.vue"),
                    meta: { title: "Dashboard" }
                }
            ]
        },
        {
            path: "/product",
            name: "product",
            meta: { title: "商品管理" },
            component: Layout,
            children: [
                {
                    path: "/product/trademark",
                    name: "TradeMark",
                    component: () => import("@/views/product/TradeMark.vue"),
                    meta: { title: "品牌管理" }
                },
                {
                    path: "/product/attr",
                    name: "AttrIndex",
                    component: () => import("@/views/product/AttrIndex.vue"),
                    meta: { title: "属性管理" }
                },
                {
                    path: "/product/sku",
                    name: "SkuIndex",
                    component: () => import("@/views/product/SkuIndex.vue"),
                    meta: { title: "SKU管理" }
                },
                {
                    path: "/product/spu",
                    name: "SpuIndex",
                    component: () => import("@/views/product/SpuIndex.vue"),
                    meta: { title: "SPU管理" }
                },
            ]
        },
        {
            path: '/permission',
            name: 'permission',
            component: Layout,  
            meta: { title: '权限管理' },
            children: [
                {
                    path: '/permission/user',
                    name: 'UserList',
                    component: () => import('@/views/permission/UserList.vue'),
                    meta: { title: '用户管理' }
                },
                {
                    path: '/permission/role',
                    name: 'RoleList',
                    component: () => import('@/views/permission/RoleList.vue'),
                    meta: { title: '角色管理' }
                },
                {
                    path: '/permission/menu',
                    name: 'MenuList',
                    component: () => import('@/views/permission/MenuList.vue'),
                    meta: { title: '菜单管理' }
                },
            ]
        },
        {
            path: '/personal',
            name: 'personal',
            component: Layout,
            meta: { title: '个人中心' },
            children: [
                {
                    path: '/personal/info',
                    name: 'information',
                    component: () => import('@/views/personal/InforMation.vue'),
                    meta: { title: '基本信息' }
                },
                {
                    path: '/personal/password',
                    name: 'password',
                    component: () => import('@/views/personal/PassWord.vue'),
                    meta: { title: '密码管理' }
                },
            ]
        }
    ]
});

// 导出路由
export default router;